#include <asm.h>
#include <csr.h>

ENTRY(setup_exception)
  /* TODO: 
   * save exception_handler_entry into STVEC
   * enable global exceptions */
   addi sp,sp,-24
   sd ra,0(sp)
   sd t0,8(sp)
   sd t1,16(sp)
   jal lock_kernel
   ld ra,0(sp)
   ld t0,8(sp)
   ld t1,16(sp)
   addi sp,sp,24
   lui t1,%hi(exception_handler_entry)
   addi t1,t1,%lo(exception_handler_entry)
   csrw stvec,t1
   //addi t1,zero,0x333
   //csrw sie,t1
   csrw sip,zero
   csrw scause,zero
   //addi t1,zero,0x22
   //csrw sstatus,t1
   jr ra
ENDPROC(setup_exception)
